package com.corona.game;

import com.badlogic.gdx.audio.Music;
import com.corona.Game;
import com.corona.game.util.audio.AudioLoader;
import java.util.Iterator;

/* compiled from: PkmnMap.java */
/* loaded from: pokewilds.jar:com/pkmngen/game/RegigigasOutroAnim.class */
class RegigigasOutroAnim extends Action {
    int timer = 0;
    int phase = 0;
    Tile regiTile;
    Tile pedistalTile;
    Music soundEffect;
    Music soundEffect2;

    public RegigigasOutroAnim(Action nextAction) {
        super(new Object[0]);
        this.nextAction = nextAction;
    }

    @Override // com.corona.game.Action
    public void firstStep(Game game) {
        Iterator<Tile> it = game.map.tiles.values().iterator();
        while (true) {
            if (!it.hasNext()) {
                break;
            }
            Tile tile = it.next();
            if (tile.name.equals("cave1_regi2")) {
                this.regiTile = tile;
                break;
            }
        }
        this.soundEffect2 = AudioLoader.loadMusic("sounds/splash1.ogg");
        this.soundEffect2.setLooping(false);
        this.soundEffect2.setVolume(0.3f);
        this.soundEffect = AudioLoader.loadMusic("sounds/stomp1.ogg");
        this.soundEffect.setLooping(true);
        this.soundEffect.setVolume(0.7f);
    }

    @Override // com.corona.game.Action
    public void step(Game game) {
        if (this.phase == 0) {
            if (this.timer == 0) {
                this.soundEffect.play();
            }
            if (this.timer < 40 * 8) {
                if (this.timer % 4 == 0) {
                    game.cam.translate(0.0f, 2.0f);
                    game.player.position.add(0.0f, 2.0f);
                    this.regiTile.sprite.translateY(2.0f);
                } else if (this.timer % 4 == 2) {
                    game.cam.translate(0.0f, -2.0f);
                    game.player.position.add(0.0f, -2.0f);
                    this.regiTile.sprite.translateY(-2.0f);
                }
            }
            if (this.timer == 40 * 2) {
                this.regiTile.sprite.setRegion(96, 0, 32, 32);
            } else if (this.timer == 40 * 4) {
                this.regiTile.sprite.setRegion(64, 0, 32, 32);
            } else if (this.timer == 40 * 6) {
                this.regiTile.sprite.setRegion(32, 0, 32, 32);
            } else if (this.timer == 40 * 8) {
                this.regiTile.sprite.setRegion(0, 0, 32, 32);
                this.soundEffect.stop();
            } else if (this.timer == 40 * 9) {
                this.phase = 1;
                this.timer = 0;
            }
        } else if (this.phase == 1) {
            this.regiTile.name = "cave1_regi1";
            this.soundEffect.dispose();
            this.soundEffect2.stop();
            this.soundEffect2.dispose();
            game.actionStack.remove(this);
            game.insertAction(this.nextAction);
        }
        this.timer++;
    }
}
